Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/block priofees #274

Merged
merged 64 commits into from
Jan 25, 2024
Merged

Feature/block priofees #274

merged 64 commits into from
Jan 25, 2024

Conversation

grooviegermanikus
Copy link
Collaborator

@grooviegermanikus grooviegermanikus commented Jan 15, 2024

Local testing

use this logging settings:

RUST_LOG=info,lite_rpc=debug,solana_lite_rpc_block_priofees=trace

tested against mainnet: http://mango.rpcpool.com/.....

Request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getLatestBlockPrioFees",
  "params": []
}

Response:

{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 243836394
    },
    "value": {
      "by_tx": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        1,
        100,
        100,
        610,
        3151,
        4500,
        5075,
        9868,
        19736,
        30040,
        30124,
        50000,
        100000,
        8486574
      ],
      "by_tx_percentiles": [
        0,
        0.05,
        0.1,
        0.15,
        0.2,
        0.25,
        0.3,
        0.35,
        0.4,
        0.45,
        0.5,
        0.55,
        0.6,
        0.65,
        0.7,
        0.75,
        0.8,
        0.85,
        0.9,
        0.95,
        1
      ],
      "by_cu": [
        0,
        0,
        0,
        0,
        0,
        0,
        1,
        100,
        677,
        1000,
        2600,
        3600,
        5000,
        8333,
        10003,
        25000,
        30107,
        30120,
        50000,
        194939,
        8486574
      ],
      "by_cu_percentiles": [
        0,
        0.05,
        0.1,
        0.15,
        0.2,
        0.25,
        0.3,
        0.35,
        0.4,
        0.45,
        0.5,
        0.55,
        0.6,
        0.65,
        0.7,
        0.75,
        0.8,
        0.85,
        0.9,
        0.95,
        1
      ],
      "tx_count": {
        "total": 1501,
        "nonvote": 415
      },
      "cu_consumed": {
        "total": 42415372,
        "nonvote": 40134772
      }
    }
  },
  "id": 1
}

Websocket:

 Received Text: {"jsonrpc":"2.0","method":"blockPrioritizationFeesNotification","params":{"subscription":3026874038738617,"result":{"context":{"slot":243836441},"value":{"by_tx":[0,0,0,0,0,4,100,1000,1000,1000,3800,5000,9180,12500,20000,30130,40000,40000,50198,59077,179765586],"by_tx_percentiles":[0.0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0],"by_cu":[0,0,0,0,2,100,800,1000,1000,1000,1500,3700,5000,5990,10003,10003,24848,30143,40000,110000,179765586],"by_cu_percentiles":[0.0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0],"tx_count":{"total":1450,"nonvote":382},"cu_consumed":{"total":37565771,"nonvote":35322971}}}}}

block_priofees/src/block_priofees.rs Outdated Show resolved Hide resolved
block_priofees/src/block_priofees.rs Outdated Show resolved Hide resolved
};
prio_fees_in_block.sort_by(|a, b| a.0.cmp(&b.0));

let median_index = prio_fees_in_block.len() / 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The priority fees should be done by CU and transaction count.

@grooviegermanikus grooviegermanikus marked this pull request as ready for review January 17, 2024 16:25
@mschneider
Copy link
Contributor

tested against mainnet: https://api.testnet.rpcpool.com/

the url is a testnet cluster, the comment says mainnet, please clarify

@mschneider
Copy link
Contributor

mschneider commented Jan 19, 2024

when i just tried to connect i wasn't able to open a websocket connection to the staging deployment

mxa:mango-router max$ yarn wscat --connect wss://api.mngo.cloud/lite-rpc-staging/v1
yarn run v1.22.15
$ /Users/max/Code/mango-router/node_modules/.bin/wscat --connect wss://api.mngo.cloud/lite-rpc-staging/v1
error: Unexpected server response: 200
error Command failed with exit code 255.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
mxa:mango-router max$ yarn wscat --connect wss://api.mngo.cloud/lite-rpc/v1/
yarn run v1.22.15
$ /Users/max/Code/mango-router/node_modules/.bin/wscat --connect wss://api.mngo.cloud/lite-rpc/v1/
Connected (press CTRL+C to quit)
✨  Done in 6.10s.

@mschneider
Copy link
Contributor

Tried to invoke via regular http rpc request and had no success either, just got a very generic response:
Welcome to mngo.cloud!

block_priofees/src/block_priofees.rs Outdated Show resolved Hide resolved
block_priofees/src/block_priofees.rs Show resolved Hide resolved
let mut agg: u64 = 0;
for (prio, cu) in prio_fees_in_block {
agg += cu;
for p in (0..=100).step_by(5) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This algorithm is suboptimal, it is O(M*N) complex which can be converted to O(M) + O(N) by creating an array of increasing CU after executing the transaction and then in another pass comparing with percentage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

lite-rpc/examples/send_udp_too_long.rs Outdated Show resolved Hide resolved
@godmodegalactus godmodegalactus merged commit 7171b52 into main Jan 25, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants